﻿/// <summary>
/// 泛型单例类
/// </summary>
/// <typeparam name="T"></typeparam>
public class Singleton<T> where T : class,new()
{
    private static readonly object __lock = new object();
    private static T __instance;
    public static T Instance
    {
        get
        {
            if (__instance == null)
            {
                lock (__lock)
                {
                    if (__instance == null)
                        __instance = new T();
                }
            }
            return __instance;
        }
    }  
}
